﻿using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.Logging;
using System.Net;
using System.Runtime.CompilerServices;

namespace yongGu
{
    public class GlobalExceptions : IExceptionFilter
    {
        public GlobalExceptions()
        {
        }
        public void OnException(ExceptionContext context)
        {
            if (!context.ExceptionHandled)
            {
                var result = new ResponseData<string>()
                {
                    Data = new string[] { "操作错误" },
                    Message = "操作错误",
                    SystemCode = -1
                };
                context.HttpContext.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
                context.ExceptionHandled = true;
            }
        }
    }
}
